package com.glela.platform.model;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;

/********************************************
 * 
 * <dl>
 * <dt>DB变化过程日志类</dt>
 * </dl>
 * 
 * @author gwq
 * @date 2017年7月24日 13:44:05
 * 
 ********************************************/
public class ChangeProcessLog {
	private Long id;// ID
	private String method; // 相关方法名
	private String tableName; // 表名
	private String primaryID; // 主键ID
	private String beforeData; // 变化前json
	private String afterData; // 变化后json
	private String description; // 描述
	private String createdTime; // 创建时间
	private Map<String, Object> beforeMap;
	private Map<String, Object> afterMap;

	public ChangeProcessLog() {
		super();
		this.beforeMap = new HashMap<String, Object>();
		this.afterMap = new HashMap<String, Object>();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(String createdTime) {
		this.createdTime = createdTime;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getPrimaryID() {
		return primaryID;
	}

	public void setPrimaryID(String primaryID) {
		this.primaryID = primaryID;
	}

	public String getBeforeData() {
		if(beforeMap!=null&&beforeMap.size()>0){
			return JSON.toJSONString(beforeMap);
		}
		return beforeData;
	}

	public void setBeforeData(String beforeData) {
		this.beforeData = beforeData;
	}

	public String getAfterData() {
		if(afterMap!=null&&afterMap.size()>0){
			return JSON.toJSONString(afterMap);
		}
		return afterData;
	}

	public void setAfterData(String afterData) {
		this.afterData = afterData;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Map<String, Object> getBeforeMap() {
		return beforeMap;
	}

	public void setBeforeMap(Map<String, Object> beforeMap) {
		this.beforeMap = beforeMap;
	}

	public Map<String, Object> getAfterMap() {
		return afterMap;
	}

	public void setAfterMap(Map<String, Object> afterMap) {
		this.afterMap = afterMap;
	}

}